package com.skb.core.dao;

import com.skb.core.model.UserRole;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

@Repository("userRoleDao")
public class UserRoleDaoImpl implements CrudDao<UserRole> {

    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public UserRole create(UserRole role) {
        sessionFactory.getCurrentSession().persist(role);
        return role;
    }

    @Override
    public UserRole get(Serializable id) {
        return (UserRole) sessionFactory.getCurrentSession().get(UserRole.class, id);
    }

    @Override
    public UserRole update(UserRole role) {
        sessionFactory.getCurrentSession().update(role);
        return role;
    }

    @Override
    public void delete(UserRole role) {
        sessionFactory.getCurrentSession().delete(role);
    }
}
